package com.shanghaionstar.nav;

import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.view.Gravity;
import android.view.View;
import android.view.Window;

import com.onstar.cn.framework.annotation.ContentView;
import com.onstar.cn.framework.annotation.FindViewById;
import com.onstar.cn.framework.mvp.base.core.BaseActivity;
import com.onstar.cn.framework.mvp.base.core.BasePresenter;
import com.onstar.cn.vehicle.result.PollingResult;
import com.onstar.cn.weight.CustomButton;
import com.shanghaionstar.R;

/**
 * Created by 6335yz on 2016/9/5.
 */
@ContentView(R.layout.nav_vehicle_alert_dialog)
public class NavLocationDialogActivity extends BaseActivity {
    @FindViewById
    private CustomButton dialog_confirm, dialog_cancel;
    private PollingResult pollingResult;

    @Override
    public BasePresenter getPresenter() {
        return null;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        pollingResult = (PollingResult) getIntent().getSerializableExtra("pollingResult");
        dialog_confirm.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(NavLocationDialogActivity.this, NavActivity.class);
                intent.putExtra("isShowToMap", true);
                intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                intent.putExtra("pollingResult", pollingResult);
                finish();
                startActivity(intent);
            }
        });
        dialog_cancel.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                finish();
            }
        });
    }

    @Override
    protected void onResume() {
        super.onResume();
        Window window = getWindow();
        DisplayMetrics dm = new DisplayMetrics();
        getWindowManager().getDefaultDisplay().getMetrics(dm);
        window.setLayout((int) (dm.widthPixels * 0.97), (int) (dm.heightPixels * 0.35));//Here!
        window.setGravity(Gravity.CENTER);
    }
}
